package com.akupilih.app;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class VisiMisiFragment extends Fragment {

	private FragmentActivity myContext;
	Button btnVisi;
	String id_capres, id_cawapres;
	Uri uriUrl;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View rootView = inflater.inflate(R.layout.fragment_profile_detail,
				container, false);
		String file_jokowi = "http://kpu.go.id/koleksigambar/VISI_MISI_Jokowi-JK.pdf";
		String file_prabowo = "http://selamatkanindonesia.com/Agenda-Prabowo-Hatta.pdf";
		id_capres = getArguments().getString("capres");
		id_cawapres = getArguments().getString("cawapres");
		if (id_capres.equals("ps")) {
			uriUrl = Uri
					.parse("https://docs.google.com/gview?embedded=true&url="
							+ file_prabowo);
		}
		if (id_capres.equals("jw")) {
			uriUrl = Uri
					.parse("https://docs.google.com/gview?embedded=true&url="
							+ file_jokowi);
		}
		btnVisi = (Button) rootView.findViewById(R.id.btnVisi);
		btnVisi.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
				startActivity(launchBrowser);

			}
		});

		return rootView;
	}

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
		myContext = (FragmentActivity) activity;

	}

}
